package com.tedu.order.service.impl;

import com.tedu.order.mapper.OrderMapper;
import com.tedu.order.pojo.dto.OrderQuery;
import com.tedu.order.pojo.entity.Order;
import com.tedu.order.pojo.vo.OrderVO;
import com.tedu.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderMapper orderMapper;
    @Override
    public List<OrderVO> selectOrder(OrderQuery query) {
        log.debug("查询订单业务:select{}",query);
        List<OrderVO> list = orderMapper.select(query);
        return list;
    }

    @Override
    public void create(Order order) {
        log.debug("创建订单业务:create{}",order);
        log.debug(order.getStatus().toString());
        order.setCreateTime(new Date());
        orderMapper.insert(order);
    }

    @Override
    public void deleteById(Long id) {
        log.debug("删除订单业务:deleteById{}",id);
        orderMapper.delete(id);
    }

    @Override
    public void update(Order order) {
        log.debug("更新订单业务:update{}",order);
        order.setUpdateTime(new Date());
        orderMapper.update(order);
    }
}
